import  datetime
from scrapy import cmdline
def begin():
   cmdline.execute(['scrapy','crawl','jipiao'])
def timerFun(sched_Timer ):
    flag=0
    while(1):
        now=datetime.datetime.now()
        if now==sched_Timer:
            begin()
            flag=1
        else:
            if flag==1:
                sched_Timer=sched_Timer+datetime.timedelta(hours=5)
                flag=0
if __name__=='__main__':
    sched_Timer=datetime.datetime.now()
    print 'run the timer task at {0}'.format(sched_Timer)
    timerFun((sched_Timer))